package msu.ml.data; 
import msu.ml.core.*;
import weka.core.*;
import weka.classifiers.*;
import java.util.*;
import java.io.*;
import javax.imageio.*;
import java.awt.image.*;
import java.awt.*;


public class ClassifierSerializerPostProcessor extends DataPostProcessorAdapter
{
   private String fileName;

	public ClassifierSerializerPostProcessor (String fileName)
	{
      this.fileName = fileName;
	}

	public void beginExperiment(Experiment e)
	{
		super.beginExperiment(e);
	}

	public void beginInstances(String name) { }
	public void endInstances() { }
	public void process(Instance data, double[] distribution) { }

	public void endExperiment()
	{
		Experiment exp = getExperiment();
		Classifier c = exp.getClassifier();
      try
      {
         weka.core.SerializationHelper.write(this.fileName, c);
      }
      catch(Exception e)
      {
         System.out.println("Failer serializing classifier to " + this.fileName);
      }
	}
}
